package cn.fz.learn02.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// @EnableKnife4j
@Configuration
public class Knife4jConfig {
    @Bean
    public OpenAPI openAPI(){
        return new OpenAPI()
                .info(info())
                .externalDocs(externalDocs());
    }

    private ExternalDocumentation externalDocs(){
        return new ExternalDocumentation()
                .description("接口文档")
                .url("http://localhost:8096");
    }

    private Info info(){
        return new Info()
                .title("knife4j测试的接口文档")
                .description("这是基于knife4j-openapi3-jakarta-spring-boot-starter的接口文档")
                .version("1.0.2")
                .contact(new Contact().name("暗里着迷").email("andy@learn01.com"));
    }

    @Bean
    public GroupedOpenApi groupedOpenApi2(){
        return GroupedOpenApi.builder()
                .group("学生管理")
                .pathsToMatch("/student/**")
                .build();
    }
}
